# --------------------------------------------------
# -*- coding: utf-8 -*-
# Time: 2023/2/14 14:59
# Author: 沈凌鹏
# Version: 0.1
# File: rule.py
# Description: 罚球比赛规则
# --------------------------------------------------
import random

class GameRule:
    def __init__(self, direction):
        self.direction = direction

    # 进球比赛规则
    def rule_1(self):
        # npc踢球或守球的方向
        npc_dirction = random.randint(1, 3)
        # 相同方向未进球
        if self.direction == npc_dirction:
            # 失球负1分
            my_point = -1
            print("未进球")
        # 不同方向进球
        else:
            # 进球的1分
            my_point = 1
            print("进球")
        # 本次得分
        return my_point

    # 玩家得分规则
    def player_rule(self, flag, win, player_point):
        # 我方罚球,罚球进了
        if flag == 1 and win == 1:
            return player_point + 1
        # 我方罚球,罚球未进
        else:
            return player_point

    # npc得分规则
    def npc_rule(self, flag, win, npc_point):

        # npc罚球,罚球进了
        if flag == 0 and win == 1:
            return npc_point + 1
        # npc罚球,罚球未进
        else:
            return npc_point
